package com.sh.shanhuo.adapter;

import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.sh.shanhuo.R;
import com.sh.shanhuo.database.sort.SortInfoEntity;
import com.sh.shanhuo.database.web.WebInfoDBUtils;

import java.util.List;

public class EditSortAdapter extends BaseQuickAdapter<SortInfoEntity, BaseViewHolder> {

    public EditSortAdapter(List<SortInfoEntity> sortInfoEntities) {
        super(R.layout.edit_sort_view, sortInfoEntities);
    }

    @Override
    protected void convert(BaseViewHolder helper, SortInfoEntity item) {
        TextView filterName = helper.getView(R.id.title);
        TextView childSize = helper.getView(R.id.childSize);
        filterName.setText(item.sortName);
        int size = WebInfoDBUtils.getWebInfoBySortId(childSize.getContext(), item.sortName).size();
        childSize.setText(new StringBuilder().append("(").append(size).append(")"));
    }
}
